package com.zonhar.autofeed.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zonhar.autofeed.common.R;
import com.zonhar.autofeed.common.enums.FeedTypeEnum;
import com.zonhar.autofeed.entities.dto.QueryPageDto;
import com.zonhar.autofeed.entities.entity.AutoFeedWeightEntity;
import com.zonhar.autofeed.service.AutoFeedWeightService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auto/feed")
public class AutoFeedController {

    @Autowired
    private AutoFeedWeightService autoFeedWeightService;

    /**
     * 分页查询
     * @return
     */
    @PostMapping("/queryPage")
    public R queryPage(@RequestBody QueryPageDto queryPageDto){
        Page<AutoFeedWeightEntity> pageInfo = autoFeedWeightService.queryPage(queryPageDto);
        return R.ok().put("page",pageInfo);
    }

    /**
     * 手动投喂
     * @param releaseNum
     * @return
     */
    @PostMapping("/sdFeed")
    public R sdFeed(Integer releaseNum){
        AutoFeedWeightEntity autoFeedWeightEntity = autoFeedWeightService.saveInfo(FeedTypeEnum.SD_FEED, 0, releaseNum);
        return R.ok().put("data",autoFeedWeightEntity);
    }

}
